<?php
if( !defined('BASE') ) exit('Access Denied!');

/**
 * Obullo Framework (c) 2009.
 *
 * PHP5 MVC-min Framework software for PHP 5.2.4 or newer
 * Derived from Code Igniter 
 * 
 * @package         obullo       
 * @author          obullo.com
 * @copyright       Ersin Güvenç (c) 2009.
 * @filesource
 * @license
 */

/**
 * Obullo Compressor Class
 *
 * @package     Obullo
 * @subpackage  Libraries
 * @category    Language
 * @author      Ersin Güvenç  
 * @link        
 */
class OB_Compressor
{
    /**
    * Constructor
    *
    * @access    public
    */
    public function __construct()
    {
        log_message('debug', "Compressor Class Initialized");
    }

    // --------------------------------------------------------------------

    /**
    * @author  http://gadelkareem.com/
    * @link    http://gadelkareem.com/2007/06/23/
    *          compressing-your-html-css-and-javascript-using-simple-php-code/
    * @param   string $css file url 
    * @return  string
    */
    function css_compress($css)
    {
        $css = file_get_contents($css);
        
        $css = preg_replace('!//[^\n\r]+!', '', $css);  // comments
         
        $css = preg_replace('/[\r\n\t\s]+/s', ' ', $css);  // new lines, multiple spaces/tabs/newlines

        $css = preg_replace('#/\*.*?\*/#', '', $css);  // comments
         
        $css = preg_replace('/[\s]*([\{\},;:])[\s]*/', '\1', $css); // spaces before and after marks
         
        $css = preg_replace('/^\s+/', '', $css); // spaces on the begining
         
        return $css;
    }
    
}
// END Compressor Class

/* End of file Compressor.php */
/* Location: ./base/base/Compressor.php */
